<script setup lang="ts">
import { MsgEnum } from '@/enums'
import Text from '@/components/Chat/RenderMessage/text.vue'
import type { MsgType } from '@/services/types.ts'
import { useUserStorage } from '@/stores/user.ts'

const componentMap = {
  [MsgEnum.TEXT]: Text,
}

defineProps<{ message: MsgType }>()

const userStore = useUserStorage()
</script>

<template>
  <component
    :is="componentMap[message.type as keyof typeof componentMap]"
    :body="message.body"
    :data-message-id="message.id"
    :draggable="userStore.isLogin ? 'true' : 'false'"
  />
</template>

<style scoped lang="scss"></style>
